package com.example.admin.system.controller;

import com.example.admin.system.bean.dto.ApiResponseDTO;
import com.example.admin.system.bean.dto.UserDTO;
import com.example.admin.system.bean.vo.UserVO;
import com.example.admin.system.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * test controller.
 *
 * @author liucheng
 * @since 0.1 2021-07-23 7:43 PM
 **/
@RestController
@RequestMapping("test")
public class TestController {
    private final UserService userService;

    public TestController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping("/test1")
    public ApiResponseDTO<UserDTO> test1() {
        UserVO userVO = userService.getUser("11");
        UserDTO userDTO = new UserDTO();
        BeanUtils.copyProperties(userVO, userDTO);
        return ApiResponseDTO.<UserDTO>builder().data(userDTO).build();
    }

    @GetMapping("/login")
    public ApiResponseDTO<String> login() {
        return ApiResponseDTO.<String>builder().data("success").build();
    }
}
